package com.example.demo.service;

import com.example.demo.entity.InstrumentCollection;
import com.example.demo.entity.NotationCollection;
import com.example.demo.mapper.InstrumentCollectionMapper;
import com.example.demo.mapper.NotationCollectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NotationCollectionImpl implements NotationCollectionService{

    @Autowired
    private NotationCollectionMapper notationCollectionMapper;

    @Override
    public boolean addCollection(NotationCollection notationCollection) {
        return notationCollectionMapper.addCollection(notationCollection) > 0;
    }

    // 删除收藏（修改后接收 InstrumentCollection 对象）
    @Override
    public boolean deleteCollection(NotationCollection notationCollection) {
        return notationCollectionMapper.deleteCollection(notationCollection.getUser_id(), notationCollection.getNotation_id()) > 0;
    }

    @Override
    public List<NotationCollection> getCollectionsByUserId(Integer userId) {
        return notationCollectionMapper.getCollectionsByUserId(userId);
    }

    @Override
    public boolean isCollected(Integer userId, Integer notationId) {
        return notationCollectionMapper.checkIfCollected(userId, notationId) > 0;
    }

    //点击量
    @Override
    public Integer incrementViewCount(Integer notationId) {
        return notationCollectionMapper.incrementViewCount(notationId);
    }

}
